<!DOCTYPE html>
<html lang="en">
<head>
	<{include file="header.html"}>
	<title>题库管理-<{$user_data['school_name']}>-德安信会计在线教育平台</title>
</head>
<body>
<div class="wrap">
	<!--star left-->
	<div class="column">
		<{include file="left_menu.html"}>
	</div>
	<div id="ContMianBox">
		<!--star子栏目-->
		<div class="sub-colum">
            <div class="tit"><{$left_menu_min.menu}></div>
            <ul>
                <{foreach from=$left_menu_min.list item=item}>
                <li <{if $item['url'] == $left_menu_min.curr}>class="curr"<{/if}>><a href="<{$item['url']}>"><{$item['name']}></a></li>
                <{/foreach}>
            </ul>
        </div>
		<!--end子栏目-->
		<!--end left-->
		<div class="container narrow">
		    <!--star conter-->
		    <div class="cetContent">
				<div class="tit p-lr20">
				    <span class="curr">题目管理</span>
				    <span><a href="/tiku/add_topic">添加题目</a></span>
				    <span><a href="/tiku/import">导入题目</a></span>
				</div>
				<!--star内容区域-->
				<div class="mainScroll">
				    <div class="mainContainer line-all">
				        <!--star tabMainCont-->
				        <div class="tabMainCont">
				            <!--star会员管理-->
							<fieldset class="layui-elem-field">
						  		<legend>筛选</legend>
					  			<div class="layui-field-box">
  									<form class="layui-form layui-form-pane1" method="post" action="/tiku/index">
				                    	<div class="layui-form-item">
								            <div class="layui-inline">
									            <select name="subject_id" id="subject_id" lay-filter="subject">
						                        	<option value="0">选择科目</option>
	                                                <{foreach from=$subject item=item}>
	                                                    <option value="<{$item.id}>" <{if isset($conditions['subject_id']) AND $conditions['subject_id'] == $item.id}>selected<{/if}>><{$item.title}></option>
	                                                <{/foreach}>
	                                            </select>
										  	</div>

										  	<div class="layui-inline">
									            <select name="chapter_id" id="chapter_id" lay-filter="chapter_id">
													<option value="0">选择章节</option>
													<{if $chapter_list_data|count  > 0}>
														<{foreach from=$chapter_list_data item=item}>
															<{if $item.sub|count > 0}>
																<{foreach from=$item.sub item=item1}>
																	<optgroup label="<{$item1.title}>">
																	<{if $item1.sub|count > 0}>
																		<{foreach from=$item1.sub item=item2}>
																			<option <{if $item2.id == $topic_info.chapter_id}> selected <{/if}> value="<{$item2.id}>"><{$item2.title}></option>
																		<{/foreach}>
																	<{/if}>
																	</optgroup>
																<{/foreach}>
															<{/if}>
														<{/foreach}>
													<{/if}>
												</select>
										  	</div>

										  	<div class="layui-inline">
									    		<input type="text" class="layui-input" style="width:200px;" placeholder="题干"  name="subject_text" value="<{if isset($conditions['subject_text']) AND $conditions['subject_text'] != 0}><{$conditions['subject_text']}><{/if}>" />
									    	</div>
								    	</div>

								    	<div class="layui-form-item">
								    		<div class="layui-inline">
									    		<select name="type">
					                            	<option value="0" <{if isset($conditions['type']) AND $conditions['type'] == 0}>selected<{/if}>>题型</option>
						                            <option value="1" <{if isset($conditions['type']) AND $conditions['type'] == 1}>selected<{/if}>>单选题</option>
						                            <option value="2" <{if isset($conditions['type']) AND $conditions['type'] == 2}>selected<{/if}>>多选题</option>
						                            <option value="3" <{if isset($conditions['type']) AND $conditions['type'] == 3}>selected<{/if}>>判断题</option>
						                            <option value="4" <{if isset($conditions['type']) AND $conditions['type'] == 4}>selected<{/if}>>计算分析题</option>
						                            <option value="7" <{if isset($conditions['type']) AND $conditions['type'] == 7}>selected<{/if}>>不定向选择题</option>
						                        </select>
									    	</div>

									    	<div class="layui-inline">
									            <select name="difficulty_level">
						                        	<option value="0">题目难易度</option>
	                                                <option value="3" <{if $conditions.difficulty_level == 3}>selected<{/if}>>难</option>
	                                                <option value="2" <{if $conditions.difficulty_level == 2}>selected<{/if}>>中</option>
	                                                <option value="1" <{if $conditions.difficulty_level == 1}>selected<{/if}>>易</option>
	                                            </select>
										  	</div>

									    	<!-- <div class="layui-inline">
									    		<select name="source_type">
						                            <option value="0" <{if isset($conditions['source_type']) AND $conditions['source_type'] == 0}>selected<{/if}>>题目来源</option>
						                            <option value="1" <{if isset($conditions['source_type']) AND $conditions['source_type'] == 1}>selected<{/if}>>系统</option>
						                            <option value="2" <{if isset($conditions['source_type']) AND $conditions['source_type'] == 2}>selected<{/if}>>自有</option>
						                        </select>
									    	</div> -->
									    	<div class="layui-inline">
                                                <input type="text" name="st" placeholder="开始日"  class="layui-input" value='<{if $conditions['st'] != 0}><{$conditions['st']}><{/if}>' id="LAY_demorange_s">
                                            </div>
                                            <div class="layui-inline">
                                                <input type="text" name="et" placeholder="截止日"  class="layui-input" value='<{if $conditions['et'] != 0}><{$conditions['et']}><{/if}>' id="LAY_demorange_e">
                                            </div>
								    		<div class="layui-inline">
									    		<button type="submit" class="layui-btn">搜索</button>
									    		<a class="layui-btn" href="/tiku/add_topic"><i class="layui-icon"></i> 新增题目</a>
									    	</div>
								    	</div>
				                    </form>
		                    	</div>
							</fieldset>
			                	<form class="layui-form layui-form-pane1" method="post" delete_action="/tiku/delete">
				                    <table class="layui-table" lay-even lay-skin="row">
				                        <thead>
										  	 <tr>
					                            <th style="width: 120px;">序号</th>
					                            <th>题干</th>
					                            <!-- <th>题目来源</th> -->
					                            <th style="width: 100px;">题型</th>
					                            <th style="width: 80px;">难度类型</th>
					                            <th style="width: 80px;">添加日期</th>
					                            <th style="width: 80px;">操作</th>
					                        </tr>
									  	</thead>
				                        <{foreach from=$topic_list item=item}>
				                        	<tr>
					                            <td class="center">
												<input type="checkbox" name="ids[]" value="<{$item['id']}>" title="<{$item['id']}>">
									  			</td>

					                            <td class="tal not_lb" title="<{$item['subject_text']|strip_tags}>"><a href="/tiku/edit_topic/<{$item.id}>"><{$item.subject_text|strip_tags|cut_str:50}></a></td>
					                            <!-- <td class="tal not_lb"><{if $item['source_type'] == 1}>系统<{else}>自有<{/if}></td> -->
					                            <td class="tal not_lb"><{if $item['type'] == 1}>单选题<{elseif $item['type'] == 2}>多选题<{elseif $item['type'] == 3}>判断题<{elseif $item['type'] == 4}>计算分析题<{elseif $item['type'] == 7}>不定向选择题<{elseif $item['type'] == 8}>名词解释<{elseif $item['type'] == 9}>简答题<{/if}></td>
					                            <td class="tal not_lb"><{if $item['difficulty_level'] == 1}>易<{elseif $item['difficulty_level'] == 2}>中<{elseif $item['difficulty_level'] == 3}>难<{/if}></td>
					                            <td class="tal not_lb"><{$item['add_time']|date_format:'%Y-%m-%d <br/> %H:%M:%S'}></td>
					                            <td class="tal not_lb">
					                            <{if $item.source_type == 2}><div class="colorBtn"><a class="c-3283fa" href="/tiku/delete_topic/<{$item.id}>">删除</a></div><{/if}>
					                            </td>
					                        </tr>
				                        <{/foreach}>
				                        	<tr>
												<td class="center" colspan="6">
													<input type="checkbox" lay-filter="checkbox_all" title="全选">
													<button id="delete" class="layui-btn layui-btn-primary layui-btn-small" style="margin-top:4px;"><i class="layui-icon"></i> 批量删除</button>
												</td>
											</tr>
				                    </table>
			                    </form>

			                <div class="pages p-tb20" style="text-align:right;">
			                    <{$pagination}>
			                </div>

			            </div>
			            <!--star会员管理-->
			        </div>
				        <!--end tabMainCont-->
		        </div>

		    </div>
		</div>

	</div>
	<{include file="footer.html"}>
	<script>
		$(function(){
			$(".sub-colum").find('li').on('click',function(){//子栏目点击选中状态；
				$(this).addClass('curr').siblings().removeClass('curr');
			})
		});

		layui.use(['form', 'jquery', 'layedit'], function(){
			var form = layui.form(),$ = layui.jquery;
			form.on('select(subject)', function(data){
				var ii = layer.load();
				var subject_id = $(data.elem).val();
				$("#chapter_id").html('<option value="0">请选择章节</option>');  
				form.render('select');
				$.ajax({
					type: "POST",
					url: "/tiku/ignore_get_subject_chapter",
					dataType:"json",
					data:{subject_id:subject_id},
					success: function(result){
						layer.close(ii);
						if(result.code == 1){
							var html ='';
							$.each(result.chapter_list, function(i, obj) {
								if(obj.sub){
									html += '<optgroup label="'+ obj.title+'">';
	                                $.each(obj.sub, function(j, obj1) {
	                                    html += '<option value="'+obj1.id+'">'+obj1.title+'</option>';
	                                });
	                                html += '</optgroup>'
	                            }
							});
							$("#chapter_id").append(html);
							form.render('select');
						}
					}
				});
			});

			<{if $conditions['subject_id']|default:0 > 0}>
			$.ajax({
				type: "POST",
				url: "/tiku/ignore_get_subject_chapter",
				dataType:"json",
				data:{subject_id:"<{$conditions['subject_id']}>"},
				success: function(result){
					if(result.code == 1){
						var html ='';
						$.each(result.chapter_list, function(i, obj) {
							if(obj.sub){
								html += '<optgroup label="'+ obj.title+'">';
                                $.each(obj.sub, function(j, obj1) {
                                	if(obj1.id == "<{$conditions.chapter_id}>"){
                                		html += '<option value="'+obj1.id+'" selected>'+obj1.title+'</option>';
                                	}else{
                                		html += '<option value="'+obj1.id+'">'+obj1.title+'</option>';
                                	}
                                    
                                });
                                html += '</optgroup>'
                            }
						});
						$("#chapter_id").append(html);
						form.render('select');
					}
				}
			});
			<{/if}>
		});
	</script>
	<script>
        layui.use('laydate', function() {
            var laydate = layui.laydate;

            var start = {
                min: '2000-11-31 23:59:59',
                max: laydate.now(+1),
                istoday: false,
                choose: function(datas) {
                    end.min = datas; //开始日选好后，重置结束日的最小日期
                    end.start = datas //将结束日的初始值设定为开始日
                }
            };

            var end = {
                min: '2016-11-31 23:59:59',
                max: laydate.now(+1),
                istoday: false,
                choose: function(datas) {
                    start.max = datas; //结束日选好后，重置开始日的最大日期
                }
            };

            document.getElementById('LAY_demorange_s').onclick = function() {
                start.elem = this;
                laydate(start);
            }
            document.getElementById('LAY_demorange_e').onclick = function() {
                end.elem = this
                laydate(end);
            }

        });
    </script>
</div>
</body>
</html>
